import React, { useState } from 'react';
import QRCodeComponent from '../../components/QRCodeComponent/index';
import { CODE_TYPE_OBJ, CODE_TYPE_OBJ_TEXT } from '../../../../enum';
import './informationDisplay.less';

export default function informationDisplay  ()  {
    const [status, setStatus] = useState(0);
    const [timestamp] = useState(Date.now());

    const getStatusText = (status) => {
        const statusKey = Object.keys(CODE_TYPE_OBJ).find(key => CODE_TYPE_OBJ[key] === status);
        if (statusKey) {
            return CODE_TYPE_OBJ_TEXT[statusKey];
        }
        return '未知状态';
    };

    return (
        <div className='information_main'>
            <div className='status_container'>
                <h1>系统状态</h1>
                <p>当前状态: {getStatusText(status)}</p>
                <h1>二维码</h1>
                <QRCodeComponent status={status} timestamp={timestamp} />
            </div>
            <div className='log_show'>
                <h1>操作日志</h1>
                <p>{new Date(timestamp).toLocaleString()}:文件已拷贝完成</p>
            </div>
        </div>
    );
};
